package com.infosys.newSimpleInvertedIndex.models;

import org.apache.commons.lang3.builder.EqualsBuilder;

public class Term {
    private String term;
    private int positionInDoc;

    public Term(String term, int positionInDoc) {
        this.term = term;
        this.positionInDoc = positionInDoc;
    }

    public String getTerm() {
        return term;
    }

    public int getPositionInDoc() {
        return positionInDoc;
    }

    public void setPosistionInDoc(int positionInDoc) {
        this.positionInDoc = positionInDoc;
    }

    @Override
    public boolean equals(Object term){
        if (term == this){ return true;}
        if (term.getClass() != this.getClass()){ return false;}

        Term docTerm = (Term) term;
        return new EqualsBuilder()
            .append(this.positionInDoc, docTerm.getPositionInDoc())
            .append(this.term, docTerm.getTerm())
            .isEquals();
    }
}
